﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AtomicTypes;
using NDimArrayNamespace;

namespace QLabValues
{
    public class QFloat32NDimArray : NDimArray<AtomicTypes.QFloat32>, IQLabValue, IIsComplex
    {
        public QFloat32NDimArray(params int[] dimensionSize)
            : base(dimensionSize)
        {
        }
        public QFloat32NDimArray(QFloat32[] data, params int[] dimensionSize)
            : base(data, dimensionSize)
        {
        }

        public object Clone()
        {
            return (object)new QFloat32NDimArray(Data, DimensionSize); 
        }

        public int[] ToIndexArray()
        {
            List<int> temp = new List<int>();
            for (int i = 0; i < this.Data.Count(); i++)
                temp.Add(Convert.ToInt32(Data[i].Real) - 1);
            return temp.ToArray();
        }

        public QFloat32NDimArray GetSubArray(int[][] subNDimArrayCoordinates)
        {
            NDimArray<QFloat32> tempArray = base.GetSubNDimArray(subNDimArrayCoordinates);
            return new QFloat32NDimArray(tempArray.Data, tempArray.DimensionSize);
        }

        public QFloat32NDimArray SubAssignment(QFloat32NDimArray matrix, int[][] subNDimArrayCoordinates)
        {
            NDimArray<QFloat32> tempArray = base.SubscriptedAssignment(new NDimArray<QFloat32>(matrix.Data, matrix.DimensionSize), subNDimArrayCoordinates);
            return new QFloat32NDimArray(tempArray.Data, tempArray.DimensionSize);
        }

        public QLabValues.IQLabValueType GetEnumType()
        {
            return QLabValues.IQLabValueType.QFloat32NDimArray;
        }

        public bool LogicalValue()
        {
            for (int i = 0; i < Data.Count(); i++)
                if (Data[i].Real==0)
                    return false;
            return true;
        }
    }
}
